Repository navigation
feat(contract-document): render the contract details and create the contract document - #1329
Merged
Merged
Conversation
jordividaller
force-pushed
the
feat/pbyr-4778-contract-document-details
branch
from
September 17, 2026 11:18
853e0dc to
361601c
Compare
Base automatically changed from
feat/pbyr-4777-contract-document-employment-id
to
main
September 17, 2026 12:20
jordividaller
force-pushed
the
feat/pbyr-4778-contract-document-details
branch
from
September 17, 2026 12:25
361601c to
acb7da6
Compare
Contributor
📦 Bundle Size Report
Size Limits
Largest Files (Top 5)
View All Files (75 total)
✅ Bundle size check passed |
Contributor
📊 Coverage Report✅ Coverage increased! 🎉
Detailed BreakdownLines Coverage
Statements Coverage
Functions Coverage
Branches Coverage
✅ Coverage check passed |
Contributor
|
Deploy preview for remote-flows ready!
Deployed with vercel-action |
Contributor
|
Deploy preview for adp-cost-calculator ready!
Deployed with vercel-action |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d2be6d4. Configure here.
jordividaller
force-pushed
the
feat/pbyr-4778-contract-document-details
branch
from
September 22, 2026 09:41
fe113f5 to
780e4ea
Compare
…mmon The pieces the contract details step is built from move out of ContractorOnboarding so the standalone ContractDocument flow can share them: the create-contract-document mutation, `buildContractDetailsJsfModify`, the AI validation error extraction and messages, the contractor product identifiers, `isCMOrCMPlus`, `calculateProvisionalStartDateDescription` and `StatementOfWorkDisclaimer`. No behaviour change: onboarding imports the moved symbols from their new home, the public product identifiers are still exported from the ContractorOnboarding entry, and the onboarding hook now calls the shared `extractAiValidationError` instead of its inline copy. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ontract document
The `contract_details` step now renders the country-specific contract details form and
submitting it creates the contract document, then moves the flow to `contract_preview`.
The form is built from `GET /v1/countries/{code}/contractor-contract-details?employment_id=…`
through the shared `useContractorContractDetailsSchema`, so the currencies come from the
contractor and the schema's `default` values prefill the form. Initial values are completed
from the employment's current contract details and provisional start date. The standalone
flow has no pricing-plan step, so the product — Contractor of Record restrictions, the
Contractor Services Agreement disclaimer, the backdating rule — is read off the employment's
`contractor_type`.
The AI misclassification check behaves as in onboarding: a skippable rejection shows the
warning under the field, `canSkipAiValidation` turns true, and submitting again sends
`skip_ai_checks: true`.
New on the bag: `fieldValues`, `checkFieldUpdates`, `handleValidation`, `parseFormValues`,
`onSubmit`, `initialValues`, `meta`, `productIdentifier`, `contractDocumentId`,
`canSkipAiValidation`. New components: `ContractDocumentForm`,
`ContractDocumentSubmitButton`. `options.jsfModify.contract_details` is supported.
Part of pbyr-4778.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ord the start-date warning `ContractDocumentForm` initialised from the employment every time it mounted, so going back to the step after a submission dropped what had just been entered. It now reads the step's stored values first, as the onboarding step does. The start-date mismatch warning referred to the Basic Information step, which the standalone flow does not have: the shared helper takes the label of the compared date, and the flow names the contractor's current start date instead. Onboarding keeps its wording. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`handleStepError` was called without field metadata, so API field errors surfaced raw paths like `service_duration/expiration_date`. The hook now prettifies the parsed values against the schema fields on submit, as the onboarding hook does, and exposes them as `meta.fields` for the form to hand to `handleStepError`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ht submission The metadata ref was replaced on submit, but the form's handler had already captured the bag rendered before, whose `meta.fields` still pointed at the previous empty object. The ref now holds one object mutated per step, as the onboarding hook does, so the handler reads the labels computed for the submission it is reporting on. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…error response The shared schema query resolved an error response as a success, so a 403 or 5xx built an empty form and the flow reported itself ready with no fields and a live submit button. The query now throws on `response.error`, as the countries and contract-documents queries do. Tests answer the schema endpoint by default so the standalone flow tests no longer run through an unhandled request, and two behaviours are pinned: entered contract details are restored when coming back from the preview, and a Contractor of Record is not shown the Contractor Services Agreement disclaimer. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The standalone flow copied onboarding and prefilled the start date with the employment's provisional start date. For an existing contractor that date is in the past, which on the Plus and Contractor of Record plans immediately raised the backdating warning. The Remote platform prefills today's date for a new contract document, so the flow does the same. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…andalone flow The note compares the start date with the one given at the Basic Information step and warns when they differ. In the standalone flow the contractor already exists and the field is prefilled with today, so the note would show on nearly every open. The shared helper is back to its onboarding-only signature. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ission when the form cannot load Throwing from the schema query only left data undefined: the bag still reported isLoading false with no fields, so the submit button stayed enabled and a click sent an empty contract document. The bag now exposes the first error among the employment, contract-documents and schema queries, and the submit button is disabled while one is set. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ractor fallback Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ontractor Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ay as the start date The employment query resolves with no employment on an error response, so the bag reported no error and the submit button stayed enabled with an empty form. The bag now surfaces that as an error. The stored contract details used to override today's start date; today now wins, as the platform does and as the README states. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ning Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… helpers from their old paths Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…nts list cannot load Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
jordividaller
force-pushed
the
feat/pbyr-4778-contract-document-details
branch
from
September 22, 2026 15:05
a37a552 to
6135135
Compare
gabrielseco
approved these changes
Sep 23, 2026
1 of 2 tasks
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Third part of the standalone Contract Document flow, after #1327. The flow now renders the country-specific contract details for a contractor and creates their contract document, with the same misclassification check as contractor onboarding. The preview step is reached but not rendered yet.
Why
Partners need to create a contract document for an existing contractor without going through the whole onboarding flow. The contract details step and its AI check already exist in contractor onboarding, so the logic is shared rather than duplicated: one implementation to fix, and both flows behave the same.
There is no pricing-plan step here, so the product is read off the employment's contractor type. It drives the same things it does in onboarding: the Contractor Services Agreement disclaimer, whether the start date can be backdated, and the misclassification wording.
What changed
Toggle details
Shared code, own commit (
refactor(contract-documents): move the contract-details helpers to common)buildContractDetailsJsfModify, the AI error handling and constants, the product identifiers andStatementOfWorkDisclaimermove tosrc/common/contract-documents/.useContractorContractDetailsSchemanow throws when the schema request fails, instead of returning the error envelope. This is visible to contractor onboarding too: the query reports an error rather than a blank form.Contract Document flow
contract_detailsrenders the form built fromGET /v1/countries/{code}/contractor-contract-details?employment_id=…. The contractor's currencies and the schema's permission-gateddefaultvalues come through the existing schema hook.contract_preview. A skippable AI error shows the warning under the field, flipscanSkipAiValidation, and the next submission sendsskip_ai_checks: true. Editing any field clears the warning.errorcovers the employment and the schema fetch. A failed contract-documents listing leavescontractDocumentsundefined and does not block creation.Public API (additive,
src/index.tsx)ContractDocumentFormandContractDocumentSubmitButton.options.jsfModify.contract_detailson the flow and the hook.fieldValues,checkFieldUpdates,handleValidation,parseFormValues,onSubmit,initialValues,meta,productIdentifier,contractDocumentId,canSkipAiValidation,isSubmitting,error.ContractDocumentContractDetailsPayload,ContractDocumentContractDetailsResponse,ContractDocumentOptions.Closest look
src/flows/ContractDocument/hooks.tsx: payload building and the AI error branch.src/common/api/contractor-contract-details.ts: the shared throw-on-error change.Screenshots
Toggle screenshots
Related Resources
Testing
npm run ciandnpm run size:checkpass locallysrc/flows/ContractDocument/tests/ContractDocumentForm.test.tsx: successful creation and move to the preview, values restored on back, disclaimer left out for a Contractor of Record, AI warning then retry withskip_ai_checks: trueexample/app in a browser: pick a contractor in the Contract Document demo, fill the contract details, submit; retry after an AI warning🤖 Generated with Claude Code
Note
Medium Risk
Touches shared contract-creation and schema-fetch paths used by contractor onboarding, plus AI skip logic and employment-derived product rules that affect compliance UX and API payloads.
Overview
The standalone Contract Document flow now renders the country-specific contract details JSON-schema form, POSTs to create the document, and advances to contract preview (still a placeholder). New public pieces are
ContractDocumentForm,ContractDocumentSubmitButton, optionaloptions.jsfModify.contract_details, and a much richer flow bag (validation, submit, AI skip state,contractDocumentId, load errors, etc.).Contract-details behavior is deduplicated with contractor onboarding: create mutation, JSF modifiers, AI error handling, product constants, and the CSA disclaimer live under
src/common/contract-documents/; onboarding keeps thin re-exports.useContractorContractDetailsSchemanow throws when the schema request fails (onboarding sees a query error instead of a silent blank form).Product rules for the standalone flow come from
employment.contractor_type(no pricing-plan step): disclaimer, backdating, COR vs CM misclassification copy, andskip_ai_checkson retry when AI returns a skippableservices_and_deliverableserror. The example app wires step navigation, errors, and AI “continue anyway” UX.Tests cover happy path, back-navigation preserving values, COR without disclaimer, and AI warning → retry with
skip_ai_checks: true.Reviewed by Cursor Bugbot for commit 6135135. Bugbot is set up for automated code reviews on this repo. Configure here.